/*
* Copyright (c) 2020-2023 云南信和科技有限公司 All Rights Reserved.
* 当前软件由云南信和科技有限公司研制开发，未经公司正式同意，其他任何个人、团体不得使用复制修改.
* @author: yansheng
*/
package com.yuntu.micor.app.configure;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;


/**
 * @author yansheng
 */
@Configuration
public class BpDataSourceAutoconfigure {



    /**
     * 新的分页插件,一缓和二缓遵循mybatis的规则,
     */
    @Bean
    @Order(-2)
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //针对 update 和 delete 语句 作用: 阻止恶意的全表更新删除
        //interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
        //乐观锁
        //interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        //分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
        return interceptor;
    }




}
